GINO Graphics Suite - GINOGRAF v9.5  

Axes Annotation Control

ggSetAxesAttribs() controls both numeric and textual annotation output by the complete graph and chart routines and the routines ggAddGrid(), ggDrawAxes(), and ggDrawAxesLabels():

ggSetAxesAttribs(swi,xy,nstart,nskip,aoff,angstr,jusver,jushor,reduc,xory)

It controls the following attributes:

Annotation Position

Annotation can be positioned at two places with respect to the axes. The default position (swi=GONAXIS) is at a fixed distance either side of the axis alongside the major tick marks. The second (swi=GOFFSET) is either side of a user defined position in user space coordinates specified by the argument xory. This second option is useful for either adding additional annotation or moving the annotation out of the graph area where axes have been placed in the centre.

[C/C++]
/*  ANNOTATION POSITIONS SET BY ggSetAxesAttribs() */
#include <gino-c.h>
#include <graf-c.h>

int main(void) {
  GDIM  paper;
  int   papty;
  char *mons[12] = { "Jan","Feb","Mar","Apr","May",
    "Jun","Jul","Aug","Sep","Oct","Nov","Dec" };    

  gOpenGino();    
  xxxxx();    
  gEnqDrawingLimits(&paper, &papty);    
  ggSetGraphCharMode(GGINOMODE);   

/* DEFINE AXIS POSITIONS */    
  ggSetAxesPos(GAXISSTART,0.1*paper.xpap,
    0.5*paper.ypap,0.8*paper.xpap,GXAXIS);    
  ggSetAxesPos(GDATAORIGIN,0.1*paper.xpap,
    0.5*paper.ypap,0.8*paper.ypap,GYAXIS);    
/* DEFINE AXIS RANGES */    
  ggSetAxesScaling(GLINEARTYPE3,11,1.0,12.0,GXAXIS);
  ggSetAxesScaling(GLINEARTYPE3,10,-5.0,5.0,GYAXIS);

/* DRAW Y AXIS WITH ANNOTATION */    
  ggDrawAxes(GCARDINAL,GANTICLOCKWISE,
    GANTICLOCKWISE,GYAXIS);    

/* LABEL X AXIS WITH MONTHS AT DEFAULT POSITION */ 
  ggDrawAxesLabels(12,mons,GANTICLOCKWISE,GXAXIS);    

/* DRAW X AXIS WITH VALUES AT BOTTOM OF Y AXIS */
  ggSetAxesAttribs(GOFFSET,0.1*paper.ypap,1,0,0.0,
    0.0,GDEFAULTPOSITION,GDEFAULTPOSITION,GNOREDUCE,
    GXAXIS);    
  ggDrawAxes(GCARDINAL,GCLOCKWISE,GCLOCKWISE,GXAXIS);

  gSuspendDevice();
  gCloseGino();
  return(0);
}   
[F90]
!  ANNOTATION POSITIONS SET BY
!           ggSetAxesAttribs()    
use gino_f90
use graf_f90


  type (GDIM) paper
  character (len=3), dimension(12) :: mons = &    
    (/'Jan','Feb','Mar','Apr','May','Jun',
      'Jul','Aug','Sep','Oct','Nov','Dec'/)    
 
  call gOpenGino    
  call xxxxx    
  call gEnqDrawingLimits(paper, ipapty)    
  call ggSetGraphCharMode(GGINOMODE)   
    
! DEFINE AXIS POSITIONS    
  call ggSetAxesPos(GAXISSTART,0.1*paper%xpap, &
    0.5*paper%ypap,0.8*paper%xpap,GXAXIS)
  call ggSetAxesPos(GDATAORIGIN,0.1*paper%xpap, &
    0.5*paper%ypap,0.8*paper%ypap,GYAXIS)
! DEFINE AXIS RANGES    
  call ggSetAxesScaling(GLINEARTYPE3,11,1.0,12.0,GXAXIS)
  call ggSetAxesScaling(GLINEARTYPE3,10,-5.0,5.0,GYAXIS)    
! DRAW Y AXIS WITH ANNOTATION    
  call ggDrawAxes(GCARDINAL,GANTICLOCKWISE, &
    GANTICLOCKWISE,GYAXIS)    

! LABEL X AXIS WITH MONTHS AT DEFAULT POSITION    
  call ggDrawAxesLabels(12,mons,GANTICLOCKWISE,GXAXIS)

! DRAW X AXIS WITH VALUES AT BOTTOM OF Y AXIS    
  call ggSetAxesAttribs(GOFFSET,0.1*paper%ypap,1,0, &
    0.0,0.0,GDEFAULTPOSITION,GDEFAULTPOSITION,GNOREDUCE, &
    GXAXIS)
  call ggDrawAxes(GCARDINAL,GCLOCKWISE,GCLOCKWISE,GXAXIS)

  call gSuspendDevice
  call gCloseGino    
  stop    
  end

Annotation positions

Skipping labels

By default, as in the above example, all the axes labels, whether numeric or textual are output, from the first to the last tick mark. There may be conditions where labels need to be omitted, either for clarity or because they are too long. ggSetAxesAttribs() can be used to control which tick mark is labelled first and whether labels are to be skipped. The arguments nstart and nskip are used for this purpose. Thus if nstart=2 and nskip=1 only the even numbered tick marks would be labelled. The default condition exists when nskip is less than 0. Here nskip is automatically calculated to skip sufficient labels so that they do not overlap each other. If nskip=GNONE all the annotation values are output, which may result in overlapping characters if there is insufficient space (see use of reduc below).

Adjusting Offsets, Angle and Justification

An offset, the string angle and justification of each label can also be adjusted with ggSetAxesAttribs(). In order to appreciate this facility it is necessary to know the position of the control points about which the adjustments are made. Where the annotation is made on the axis itself (swi=GONAXIS) the control points are twice the tick mark length away from the axis, either on the clockwise or anti-clockwise side depending on the choice made in ggDrawAxes() or ggDrawAxesLabels(). Where the annotation is at the defined position xy (swi=GOFFSET) the control points are at the coordinate xy in line with the major tick marks on the corresponding axis. The control points are shown below.

Axes annotation control points

By default the offset, string angle and justifications are as shown in the following table

Control Point Offset Angle Vertical Justification Horizontal Justification
Clockwise side of X axis or Y=xory 0.0 0.0 Top Centre
Anti-clockwise side of X axis or Y=xory 0.0 0.0 Bottom Centre
Clockwise side of Y axis or X=xory 0.0 0.0 Bottom Left
Anti-clockwise side of Y axis or X=xory 0.0 0.0 Bottom Right


Each of these settings can be changed for either the X axis or Y axis with the arguments aoff, angstr, jusver, jushor respectively. The offset (aoff) is measured as a proportion of the distance between major tick marks on the specified axis. ie. where aoff=0.5, the annotation is drawn midway between the major tick mark to which it refers and the next major tick mark as shown in the example below. Altering the string angle of axes annotation is a useful method of fitting in long labels to each major tick mark on the X axis.

The final control offered by ggSetAxesAttribs() is an option to automatically reduce the size of the annotation to ensure it fits within the major tick marks without overlapping. The option is particularly useful where horizontal annotation is preferred and all the labels need to be output. When reduc is set to GREDUCE and nskip=0, the character size is reduced by the required amount (equally in both directions) so that the longest label on the axis fits between the specified number of annotated tick marks. An example showing the usage of axes annotation attributes is shown below.

Axes annotation control

[C/C++]
/*  AXIS ANNOTATION CONTROL */
#include <gino-c.h>
#include <graf-c.h>

int main(void) {
  GDIM  paper;
  int   papty;
  char *mons[12] = { "January","February","March",
    "April","May","June","July","August","September",
    "October","November","December" };
   
  gOpenGino();
  xxxxx();
  gEnqDrawingLimits(&paper,&papty);
  ggSetGraphCharMode(GGINOMODE);
/* DEFINE AXIS RANGE */
  ggSetAxesScaling(GLINEARTYPE3,11,1.0,12.0,GXAXIS);
/* DEFINE FIRST AXIS WITH DEFAULT ATTRIBUTES */
  ggSetAxesPos(GAXISSTART,0.2*paper.xpap,
    0.8*paper.ypap,0.7*paper.xpap,GXAXIS);
  ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS);
  ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS);
/* DEFINE SECOND AXIS WITH ANGLED TEXT */
  ggSetAxesPos(GAXISSTART,0.2*paper.xpap,
    0.6*paper.ypap,0.7*paper.xpap,GXAXIS);
  ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS);
  ggSetAxesAttribs(GONAXIS,0.0,1,GNONE,0.0,45.0,
    GMIDDLE,GRIGHT,GNOREDUCE,GXAXIS);    
  ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS);
/* DEFINE THIRD AXIS WITH OFFSET ANGLED TEXT */
  ggSetAxesPos(GAXISSTART,0.2*paper.xpap,
    0.4*paper.ypap,0.7*paper.xpap,GXAXIS);
  ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS);
  ggSetAxesAttribs(GONAXIS,0.0,1,GNONE,0.5,45.0,
    GMIDDLE,GRIGHT,GNOREDUCE,GXAXIS);
  ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS);
/* DEFINE FOURTH AXIS WITH REDUCED TEXT */
  ggSetAxesPos(GAXISSTART,0.2*paper.xpap,
    0.2*paper.ypap,0.7*paper.xpap,GXAXIS);
  ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS);
  ggSetAxesAttribs(GONAXIS,0.0,1,GNONE,0.0,0.0,
    GDEFAULTPOSITION,GDEFAULTPOSITION,GREDUCE,GXAXIS);
  ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS);
    
  gSuspendDevice();
  gCloseGino();
  return(0);
}
[F90]
!  AXIS ANNOTATION CONTROL     
use gino_f90
use graf_f90


  type (GDIM) paper
  character (len=9), dimension(12) :: mons = &    
    (/'January','February','March','April','May','June', &
      'July','August','September','October', 'November', &
      'December'/)
    
  call gOpenGino
  call xxxxx
  call gEnqDrawingLimits(paper, ipapty)
  call ggSetGraphCharMode(GGINOMODE)
     ! DEFINE AXIS RANGE
  call ggSetAxesScaling(GLINEARTYPE3,11,1.0,12.0,GXAXIS)
! DEFINE FIRST AXIS WITH DEFAULT ATTRIBUTES
  call ggSetAxesPos(GAXISSTART,0.2*paper%xpap, &
    0.8*paper%ypap,0.7*paper%xpap,GXAXIS)
  call ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS)
  call ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS)
! DEFINE SECOND AXIS WITH ANGLED TEXT
  call&
    0.6*paper%ypap,0.7*paper%xpap,GXAXIS)
  call ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS)
  call ggSetAxesAttribs(GONAXIS,0.0,1,GNONE,0.0,45.0, &
    GMIDDLE,GRIGHT,GNOREDUCE,GXAXIS)
  call ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS)
! DEFINE THIRD AXIS WITH OFFSET ANGLED TEXT
  call ggSetAxesPos(GAXISSTART,0.2*paper%xpap, &
    0.4*paper%ypap,0.7*paper%xpap,GXAXIS)
  call ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS)
  call ggSetAxesAttribs(GONAXIS,0.0,1,GNONE,0.5,45.0, &
    GMIDDLE,GRIGHT,GNOREDUCE,GXAXIS)
  call ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS)
! DEFINE FOURTH AXIS WITH REDUCED TEXT
  call ggSetAxesPos(GAXISSTART,0.2*paper%xpap, &
    0.2*paper%ypap,0.7*paper%xpap,GXAXIS)
  call ggDrawAxes(GCARDINAL,GCLOCKWISE,GNOVAL,GXAXIS)
  call ggSetAxesAttribs(GONAXIS,0.0,1,GNONE,0.0,0.0, &
    GDEFAULTPOSITION,GDEFAULTPOSITION,GREDUCE,GXAXIS)
  call ggDrawAxesLabels(12,mons,GCLOCKWISE,GXAXIS)
!
  call gSuspendDevice
  call gCloseGino
  stop
  end

Axes Annotation Enquiry

The user may obtain the parameters used for annotation control set up by the routine ggSetAxesAttribs() by calling ggEnqAxesAttribs():

ggEnqAxesAttribs(switch,xy,nstart,nskip,aoff,angstr,jusver,jushor,
reduc,xory)

The only parameter that the user needs to supply is xory, the number of the axis being enquired. All other parameters are returned.